﻿@using ECG.Common
@using ECG.Utility
@model IEnumerable<ProductCategoryDto>
<ul class="cateSub1 ul">
    @foreach (var itemFirst in Model)
    {
        //lay danh muc cap 2
        var childMenuList = Model.Where(m => m.ParentId == itemFirst.Id).OrderBy(m => m.Ordering);
        <li>
            <h2>
                <a href="@Url.Action("Index", "Category", new { categoryName = StringUtil.RemoveSpecialCharactersVn(itemFirst.Name), categoryId = itemFirst.Id })" class="lnkL1">
                    @itemFirst.Name
                </a>
            </h2>
            @if (childMenuList.Any())
            {
                <ul class="cateSub ul">
                    @foreach (var item in childMenuList)
                    {
                        // lay cac danh muc cap 3
                        var menuListSameLevel = Model.Where(m => m.ParentId == item.Id).OrderBy(m => m.Ordering);
                        <li>
                            <h3>
                                <a href="@Url.Action("Index", "Category", new { categoryName = StringUtil.RemoveSpecialCharactersVn(item.Name), categoryId = item.Id })" class="lnkL2">
                                    @item.Name
                                </a>
                            </h3>
                            @if (menuListSameLevel.Any())
                            {
                                <div @Html.Raw("style='display:block;'")>
                                    @foreach (var item2 in menuListSameLevel)
                                    {
                                        <h3>
                                            <a href="@Url.Action("Index", "CategoryL3", new { categoryName = StringUtil.RemoveSpecialCharactersVn(item2.Name), categoryId = item2.Id })">
                                                @item2.Name
                                            </a>
                                        </h3>
                                    }
                                </div>
                            }
                        </li>
                    }
                </ul>
            }
        </li>
    }
</ul>

